package com.itheim.orderservice.controller;

import com.itheim.orderservice.OrderServiceApplication;
import com.itheim.orderservice.bean.OrderBean;
import com.itheim.orderservice.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
@Slf4j
public class OrderController {
    @Value("${order.test}")
    private String a;

    //@Value("${spring.datasource.url}")
    private String b;

    @Autowired
    private OrderService orderService;

    @Autowired
    private RedisTemplate redisTemplate;

    @PostMapping
    public int test(){
        System.out.println(a);
        System.out.println(b);
        OrderBean orderBean = new OrderBean();
        orderBean.setName("666");
        Boolean key = redisTemplate.opsForValue().setBit("key", 10, true);
        return orderService.add(orderBean);
    }
}
